import Mock from 'mockjs'
const devAppGroup = { groupDesc: '本地开发环境', groupName: 'Development', apps: require('../project.json').filter(x => !x.base).map(x => { return { desc: x.name, name: x.name, url: x.proxyPass } }) }

/** **==========================测试数据API(拦截ajax请求，代理响应数据)===============================****/
// 获取产品
Mock.mock(/(famework\/appgroups)/, function (options) {
  console.debug('---mock---', options)
  const result = [
    devAppGroup,
    {
      groupDesc: '管控',
      groupName: 'GK',
      apps: [
        {
          desc: '云管平台',
          name: 'scorpio',
          url: 'http://localhost:8060',
          path: '/scorpio'
        },
        {
          desc: '统一权限管理系统',
          name: 'uas',
          url: 'http://localhost:8061',
          path: '/uas'
        },
        {
          desc: '告警中心',
          name: 'uwc',
          url: 'http://uwc-console.cbpmgt.com',
          path: '/uwc'
        },
        {
          desc: '统一日志',
          name: 'digger',
          url: 'http://digger.jd.com/',
          path: '/digger'
        },
        {
          desc: '统一配置中心',
          name: 'concrete',
          url: 'http://concrete.jd.com',
          path: '/concrete'
        },
        {
          desc: '性能测试平台',
          name: 'titans',
          url: 'http://digger.jd.com/',
          path: '/titans'
        },
        {
          desc: 'API网关',
          name: 'phevos',
          url: 'http://smperp.jd.com',
          path: '/phevos'
        },
        {
          desc: '弹性搜索平台',
          name: 'jec',
          url: 'http://jpu.jdfmgt.com',
          path: '/jec'
        },
        {
          desc: '网络监控平台',
          name: 'dnp',
          url: 'https://upms.jd.com/app/appcreate',
          path: '/dnp'
        },
        {
          desc: 'DTING',
          name: 'dting',
          url: 'http://juejin.jdfcloud.com',
          path: '/dting'
        },
        {
          desc: '分布式调度',
          name: 'schedule',
          url: 'http://rongjin.jdfcloud.com',
          path: '/schedule'
        }
      ]
    },
    {
      groupDesc: '网络',
      groupName: 'Network',
      apps: [
        {
          desc: 'F5Mgt',
          name: 'F5Mgt',
          url: 'http://f5.jdfmgt.com',
          path: ''
        },
        {
          desc: 'WAF',
          name: 'WAF',
          url: 'http://waf.jdfmgt.com',
          path: ''
        },
        {
          desc: 'UMC网络监控',
          name: 'umc_web3.0',
          url: 'http://umc.jdfmgt.com',
          path: ''
        },
        {
          desc: '弹性搜索平台',
          name: 'jes',
          url: 'http://ops-jes.jdfmgt.com',
          path: ''
        },
        {
          desc: 'rongjin_balance',
          name: 'rongjin_balance',
          url: 'http://rongjin-f5.jdfcloud.com',
          path: ''
        }
      ]
    },
    {
      groupDesc: '监控与管理',
      groupName: 'Monitor',
      apps: [
        {
          desc: '业务秒级监控',
          name: 'fine-monitor',
          url: 'http://fine.db.cbpmgt.com',
          path: ''
        },
        {
          desc: '天玑大数据管理平台',
          name: 'phecda',
          url: 'http://phecda.jdfcloud.com',
          path: ''
        },
        {
          desc: '服务监控与治理',
          name: 'SGM',
          url: 'http://sgm.jd.com',
          path: ''
        },
        {
          desc: '移动端监控',
          name: 'sgm-mobile',
          url: 'http://sgm-mobile.jd.com',
          path: ''
        },
        {
          desc: 'sgm前端监控',
          name: 'sgm-web',
          url: 'http://sgm-web.jd.com',
          path: ''
        },
        {
          desc: '数据标准',
          name: 'data_standards',
          url: 'http://ds.jdfmgt.com',
          path: ''
        },
        {
          desc: '京东数科开发数据库建模平台 ',
          name: 'dbcm',
          url: 'http://dbcm.jdfmgt.com/',
          path: ''
        },
        {
          desc: 'dbrep',
          name: 'dbrep',
          url: 'http://dbrep-mgt.cbpmgt.com/admin',
          path: ''
        },
        {
          desc: '分布式关系型数据库服务',
          name: 'drds',
          url: 'http://cds.jd.com',
          path: ''
        }
      ]
    },
    {
      groupDesc: '系统管理',
      groupName: 'System Manage',
      apps: [
        {
          desc: '文档中心',
          name: 'omiDocument',
          url: 'http://localhost:8060',
          path: '/scorpio/document/list'
        },
        {
          desc: '审计日志',
          name: 'omiLog',
          url: 'http://localhost:8061',
          path: '/scorpio/auditLog'
        }
      ]
    }
  ]
  return result
})

// 查询我的收藏/最近访问 /framework/product/favorite
Mock.mock(/(framework\/product\/favorite)/, function (options) {
  console.debug('---mock---', options)
  const result = [
    {
      type: 'favorite',
      desc: '云管平台',
      name: 'scorpio',
      url: 'http://localhost:8060',
      path: '/scorpio'
    },
    {
      type: 'favorite',
      desc: '统一权限管理系统',
      name: 'uas',
      url: 'http://localhost:8061',
      path: '/uas'
    },
    {
      type: 'access',
      desc: 'F5Mgt',
      name: 'F5Mgt',
      url: 'http://f5.jdfmgt.com',
      path: ''
    },
    {
      type: 'access',
      desc: '弹性搜索平台',
      name: 'jes',
      url: 'http://ops-jes.jdfmgt.com',
      path: ''
    }
  ]
  return result
})

Mock.mock(/(framework\/principal)/, function (options) {
  return { username: 'devUser' }
})
